package suncertify.db.test;

import suncertify.db.DBAccess;
import suncertify.db.RecordNotFoundException;

public class ReadRecordUser extends Thread {

    private DBAccess data;
    private long[] records;
    private int iteration;
    private long fromRecord;
    private long toRecord;

    public ReadRecordUser(String name, DBAccess data, long fromRecord, long toRecord, int iterationCount) {

	super.setName(name);
	this.data = data;
	this.iteration = iterationCount;
	this.fromRecord = fromRecord;
	this.toRecord = toRecord;
    }

    public void run() {

	for (int i = 0; i < this.iteration; ++i) {

	    // Data.log("", "================= ReadRecordsUser iteration  " + Integer.toString(i) +
	    // " ==================");

	    for (long record = this.fromRecord; record <= this.toRecord; ++record) {

		// Data.log("", "================= ReadRecordsUser readRecord  " + Long.toString(record)
		// + " ==================");

		try {

		    try {
			this.data.readRecord(record);
		    } catch (RecordNotFoundException ex) {

			// Data.log("", "====== RecordNotFoundException ID = " + Long.toString(record));
			continue;
		    }
		} catch (Exception e) {
		    e.printStackTrace();
		}
	    }
	}
    }
}
